<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<html>
<head>
    <title>词库管理</title>

</head>
<body>

<div class="content-wrapper">
    <h3>词库管理</h3>
</div>

<div class="row">


    <div class="col-sm-12 row ">
        <div class="col-sm-3"></div>
        <div class="input-group col-sm-6">

            <input type="text" class="form-control" value="" id="word" placeholder="输入分词点击查询" name="word">

            <span class="input-group-addon"  style="cursor:pointer;" onclick="addWord()"><em class="fa fa-plus-square"></em></span>
            <span class="input-group-addon"  style="cursor:pointer;" onclick="download()"><em class="fa fa-download"></em></span>

        </div>
        <div class="col-sm-3"></div>
    </div>
</div>

<div id="comfirmWin" tabindex="-10000" role="dialog" aria-labelledby="myModalLabelSmall" aria-hidden="true" class="modal fade">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" data-dismiss="modal" aria-label="Close" class="close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h4 id="myModalLabelSmall" class="modal-title">确认框</h4>
            </div>
            <div class="modal-body">确认添加分词吗？</div>
            <div class="modal-footer">
                <button type="button" data-dismiss="modal" class="btn btn-default">取消</button>
                <button type="button" class="btn btn-primary" onclick="addWordDone()">确认</button>
            </div>
        </div>
    </div>
</div>
<script>
    function download(){

        document.location.href="${ctx}/wordLibrary/download.do";
    }

    function addWord(){
        var word = $("#word").val();

        if(!word){
            notyMsg('请输入分词！');
            return;
        }
        show_sys_modal('comfirmWin');

    }
    function addWordDone(){
        var word = $("#word").val();
        $('#comfirmWin').modal('hide')
        $.ajax({
            type: 'post', cache: false, dataType: 'json', async: true,
            url: '${ctx}/wordLibrary/addWord.do?word='+word,

            success: function (resp, options) {
                if(resp.success){
                    notyMsg(resp.msg);
                }else{
                    notyMsg(resp.msg);
                }
            },

            error: function(jqXHR , textStatus , errorThrown){
                console.log("error"+errorThrown);
            },
        });
    }

</script>

</body>
</html>


</body>
</html>
